package com.example.controller.carecommunity;

import com.example.utils.Results;
import com.qiniu.util.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@CrossOrigin
@RestController
@Api(tags = "获取上传token")
@RequestMapping("/test")
public class WenjianAdd {
    @ApiOperation(value = "获得token",notes = "养老系统登录")
    @GetMapping("/getToken/{buname}")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "buname",//name
        value = "buname",//参数的描述buname 空间名
        required = true,//是否必须传入
        //paramType定义参数传递类型：有path,query,body,form,header
        paramType = "path"
    )
    })
    public Results getbyid(@PathVariable String buname){

        System.err.println(buname+"得到的空间名");
        String accessKey = "fRXLiWpJsAHlPGTzs2rCLoyKjnN6krNHFDzCG1fU"; //你自己的key
        String secretKey = "sHoVH3hex-dda9_cQa3qABL6BFS_WSt7DUbeZLkN"; //你自己的密钥
        Auth auth = Auth.create(accessKey,secretKey);
        UUID m = UUID.randomUUID();
        System.out.println(m);
        String fname = "test"+m;
        String token = auth.uploadToken("yanglaofuwuxitong",fname); //你自己空间的名称
        System.out.println(token);
        return new Results().data("token",token).data("fname",fname);
    }
}
